package com.javaweb.blogcite.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.javaweb.blogcite.pojo.BlogType;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BlogTypeMapper extends BaseMapper<BlogType> {
    @Select("select id, name, `order`, blog_type.blog_count from blog_type where id = #{id}")
    BlogType selectBlogTypeById(Integer id);

    @Select("SELECT id,name,`order`,blog_count FROM blog_type WHERE id = #{id}")
    BlogType selectCategoryById(Integer id);

    @Select("SELECT id,name,`order`,blog_count FROM blog_type ORDER BY `order` ASC")
    List<BlogType> selectCategoryByOrder();

    @Insert("INSERT INTO blog_type (name, `order`, blog_count) VALUES (#{name}, #{order}, #{blogCount})")
    int insertBlogType(BlogType blogType);

    @Update("UPDATE blog_type SET name = #{name}, `order` = #{order}, blog_count = #{blogCount} WHERE id = #{id}")
    int updateBlogType(BlogType blogType);

    @Select("select id, name, `order`, blog_count from blog_type")
    List<BlogType> selectAllBlogType();
}
